//
//  LoginController.m
//  MyCloudMusic
//
//  Created by pub on 2024/6/11.
//

#import "LoginController.h"
#import "SuperInputView.h"
#import "SuperDialogController.h"
@interface LoginController ()
@property(nonatomic, strong)SuperInputView *userNameView;
@property(nonatomic, strong)SuperInputView *posswordView;
@end

@implementation LoginController


- (void)initViews{
    [super initViews];
    [self initLinearLayoutSafeArea];
    
    [self setTitle:R.string.localizable.login];
    
    self.container.padding = UIEdgeInsetsMake(PADDING_LARGE, PADDING_OUTER, 0, PADDING_OUTER);
    
    self.container.subviewSpace = PADDING_LARGE;
    
    _userNameView = [SuperInputView withImage:R.image.inputUsername placeHolder:@"username"];
    [_userNameView smallRadius];
    [self.container addSubview:_userNameView];
    
    
    _posswordView = [SuperInputView withImage:R.image.inputPassword placeHolder:@"password"];
    [_posswordView smallRadius];
    [_posswordView passwordStyle];
    [self.container addSubview:_posswordView];

    QMUIButton *primaryButton = [ViewFactoryUtil primaryHalfFillBtn];
    [primaryButton setTitle:R.string.localizable.login forState:UIControlStateNormal];
    
    [primaryButton addTarget:self action:@selector(onPrimaryBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.container addSubview:primaryButton];
    
    
    MyRelativeLayout *btnParent = [MyRelativeLayout new];
    btnParent.myWidth = MyLayoutSize.fill;
    btnParent.myHeight = MyLayoutSize.wrap;
    [self.container addSubview:btnParent];
    
    
    //立刻注册
    QMUIButton *registerBtn = [ViewFactoryUtil linkButton];
    [registerBtn setTitle:R.string.localizable.registerNow forState:UIControlStateNormal];
    
    [registerBtn setTitleColor:[UIColor black80] forState:UIControlStateNormal];
    [registerBtn addTarget:self action:@selector(registerBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [registerBtn sizeToFit];
    [btnParent addSubview:registerBtn];
    
    
    //忘记密码
    QMUIButton *forgotPasswordBtn = [ViewFactoryUtil linkButton];
    [forgotPasswordBtn setTitle:R.string.localizable.forgotPassword forState:UIControlStateNormal];
    
    [forgotPasswordBtn setTitleColor:[UIColor black80] forState:UIControlStateNormal];
    [forgotPasswordBtn addTarget:self action:@selector(registerBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [forgotPasswordBtn sizeToFit];
    forgotPasswordBtn.myRight = 0;
    [btnParent addSubview:forgotPasswordBtn];
    
    [self initTapHideKeyboard];
    
    
    NSLog(@"%@",[UIDevice currentDevice].name);
}


- (void)registerBtnClick:(QMUIButton *)btn{
    NSLog(@"registerBtnClick");
    
    SuperDialogController *controller = [SuperDialogController new];
    controller.titleView.text = @"hahah";
    [controller setCancelButtom:@"xxx" target:self action:@selector(onPrimaryBtnClick:)];
    
    [controller setWarningButtom:@"hahahaha" target:nil action:nil];
    
    [controller show];
}

- (void)onPrimaryBtnClick:(QMUIButton *)btn{
    
}

@end
